package com.zmn.mcc.common.dto.cc;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 * 描述: 分页查询通用查询类
 *
 * @author guoqiao
 * @since 2021/4/29 14:35
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UpdateQuery implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 描述: 更新起始时间
     */
    @NotNull(message = "更新起始时间不能为空")
    private Date from;

    /**
     * 描述: 更新截止时间
     */
    @NotNull(message = "更新截止时间不能为空")
    private Date to;

    /**
     * 描述: 每页条数,默认100
     */
    private Integer pageSize = 100;

    /**
     * 描述: 页码,默认1
     */
    private Integer pageIndex = 1;

    /**
     * 描述: 分页起始位置
     */
    private Integer startIndex;

    public Integer getStartIndex() {
        int tmpPageIndex = this.getPageIndex() > 0 ? this.getPageIndex() - 1 : 0;
        this.startIndex = tmpPageIndex * this.getPageSize();
        return this.startIndex;
    }

}
